using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Xml;
using FiltronASP.Models.DAO.Interfaces;
using FiltronASP.Models.DAO;
using FiltronASP.Models;

namespace FiltronASP.Helpers.XmlHelper
{
    public class XMLHelper
    {
        public static string readXML(string name, string language) {
            string toReturn = String.Empty;
            bool right = false;

            XmlDocument doc = new XmlDocument();
            doc.Load("http://wixeurope.com/Helpers/XmlHelper/iksemel.xml");

            XmlNodeList elem = doc.GetElementsByTagName("single");
            foreach (XmlElement single in elem) {
                XmlNodeList childNodes = single.ChildNodes;
                foreach (XmlElement singleChild in childNodes) {
                    if (singleChild.Name == "name") {
                        if (singleChild.InnerText == name) {
                            right = true;
                        }
                    }
                    if (singleChild.Name == language && right == true) {
                        toReturn += singleChild.InnerText;
                    }
                    
                }
                right = false;
            } // foreach
            return toReturn;
        }

        public static string getLanguageNameById(int languageId) {
            ILanguageDAO LanguageDAO = new LanguageDAO();
            Language lang = LanguageDAO.FindByPK(languageId);
            if (lang != null) {
                return lang.language_name;
            }
            return String.Empty;
        }

        public static string testing() {
            return "test";
        }

    }
}
